import http from "@/utils/http";
import qs from 'qs';
import { PRODUCT_URL, YNGP } from '@/common/const'

/**
 * 获取热线电话
 * @param            
 * @returns {*}
 */
export const getPhone = () => {
    let url = YNGP;
    return http.get(`${YNGP}/ynstock/app/hotline/queryHotline.htm`)
};


/**
* 获取产品详情信息
* @param productId           产品ID
* @param             产品关联ID
* @param               1.锦囊,2.会员,3.策略,4.V研选,5.短线宝,9.训练营
* @returns {*}
*/
export const getProductDetail = (productId = '') => {
    // http://product.zx093.com/yngp/productAct/productListFront.htm?productId=63
    return http.get(`${PRODUCT_URL}/yngp/productAct/productListFront.htm`, {
        productId
    })
};

/**
* 生成订单
* @param productId           产品ID
* @param             产品关联ID
* @param
* productId	     产品id
   systemCode	     系统代码
   productActId	 产品价格id
   paySource	     支付来源 0web 1ios 2android 3h5
   paymark	         0 15天支付 1正常支付         1元购传1
   totalPrice	     价格
   phone	         手机号码
   repPhone	     确认手机号码
   isCheckRepPhone	 是否校验确认手机号码    0 ：不校验    1：校验
   type	         0取产品价格 1取传入价格       
* @returns {*}
*/
export const createOrder = (params) => {
    return http.post(`${PRODUCT_URL}/yngp/common/order/createYctProductOrder.htm`, {
        ...params
    })
};

/**
* 微信支付
* @param orderNum           订单号
* @param   source         
* @param   returnUrl         跳转url
* @returns {*}
*/
export const wxPay = (param) => {
    let url = `${PRODUCT_URL}/solopay/wxpay/pay/webWxPayNoUser.htm?${qs.stringify(param)}`
    return http.get(`http://product-test.zx093.com/solopay/wxpay/pay/webWxPayNoUser.htm`, {
        ...param
    })
};

/**
* 支付宝支付
* @param orderNum           订单号
* @param   source         
* @param   returnUrl         跳转url
* @returns {*}
*/
export const alipay = (params) => {
    return http.post(`${PRODUCT_URL}/solopay/alipay/web/webPayAliNoUser.htm`, {
        ...params
    })
};

/**
* 获取订单详情信息
* @param orderNum	           订单id
* @param             
* @param               
* @returns {*}
*/
export const getOrderDetail = (orderNum = '') => {
    return http.get(`${PRODUCT_URL}/yngp/common/order/findYctOrderState.htm`, {
        orderNum
    })
};